<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/taglibs/taglibs.jsp"%>
<%@ include file="/base.jsp" %>
<!DOCTYPE html>
<html>
  <head>
    <title>请假管理</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	  <!--
	<script type="text/javascript" src="${ctx}/js/app/vacation.js?_=${sysInitTime}"></script>
-->
	  <script src="${ctx}/js/HdUtil.js"></script>
	  <script type="text/javascript">

		  /**
		   * 添加请假申请
		   */

		  var vacation_form;

		  //初始化表单
		  $(function(){
             /*
			  $('#vacation_form').form({
				  url: "${ctx}/vacationAction/doAdd",
				  success: function (data) {
					  $.messager.progress('close');
					  console.log(data);
					  if ("ok" == data) {
						  $("#sysCodeDialog").dialog("close");
						  HdUtil.messager.slide(HdUtil.constant.SAVE_SUCCESS);
						  $("#sysCodeTable").datagrid("reload");
					  } else {
						  HdUtil.messager.error(data);
					  }
				  }
			  });*/

			  /**/
              vacation_form = $('#vacation_form').form({
                  url: ctx+"/vacationAction/doAdd",
                  onSubmit: function () {
                      $.messager.progress({
                          title: '提示信息！',
                          text: '数据处理中，请稍后....'
                      });
                      var isValid = $(this).form('validate');
                      if (!isValid) {
                          $.messager.progress('close');
                      }
                      return isValid;
                  },
                  success: function (data) {
                      $.messager.progress('close');
                      console.log(data);
                      var json = $.parseJSON(data);
                      console.log(json);
                      /*
                      if (json.status) {
                          $("#save").linkbutton('disable');
                          $("#clear").linkbutton('disable');
                      }*/
                      /*
                      $.messager.show({
                          title : json.title,
                          msg : json.message,
                          timeout : 1000 * 2
                      });
                      */
					  $.messager.show({
						  title : '提示',
						  msg : '流程已经发起',
						  timeout : 1000 * 2
					  });
                  }
              });

			  //只能选取今天以后的日期
			  $('#beginDate').datebox().datebox('calendar').calendar({
				  validator: function(date){
					  var now = new Date();
					  var d1 = new Date(now.getFullYear(), now.getMonth(), now.getDate());
					  return d1<=date;
				  }
			  });

			  //只能选取beginDate之后的日期
			  $('#beginDate').datebox({
				  onSelect: function(beginDate){
					  $('#endDate').datebox().datebox('calendar').calendar({
						  validator: function(date){
							  var d1 = new Date(beginDate.getFullYear(), beginDate.getMonth(), beginDate.getDate());
							  return d1<=date;
						  }
					  });
				  }
			  });

		  })

		  //表单提交
		  function submitForm(){
			  vacation_form.submit();
			  // $("#vacation_form").submit();
		  }

		  //表单重置
		  function clearForm(){
			  vacation_form.form('clear');
			  // $("#vacation_form").form('clear');
		  }



	  </script>
	<style type="text/css">
	    #fm{
	        margin:0;
	        padding:10px 30px;
	    }
	    .ftitle{
	        font-size:14px;
	        font-weight:bold;
	        padding:5px 0;
	        margin-bottom:10px;
	        border-bottom:1px solid #ccc;
	    }
	    .fitem{
	        margin-bottom:5px;
	    }
	    .fitem label{
	        display:inline-block;
	        width:80px;
	        text-align: right;
	    }
	    .fitem input{
	        width:160px;
	        margin-left: 150px;
	    }
	</style>
  </head>
  <body>
  	<div id="dlg" class="easyui-layout" style="padding:10px 20px">
	    <div class="ftitle"><img src="${ctx }/extend/fromedit.png" style="margin-bottom: -3px;"/> 请假信息</div>
	    <form id="vacation_form" method="post">
	        <div class="fitem">
	            <label>开始日期:</label>
	            <input  name="beginDate" id="beginDate" class="easyui-datebox" required="true" style="width: 160px;">
	        </div>
	        <div class="fitem">
	            <label>结束日期:</label>
	            <input  name="endDate" id="endDate" class="easyui-datebox" required="true" style="width: 160px;">
	        </div>
	        <div class="fitem">
	            <label>请假天数:</label>
	            <input  name="workDays" class="easyui-numberspinner easyui-validatebox" required="true" data-options="min:1,max:60" style="width: 160px;">
	        </div>
	        <div class="fitem">
	            <label>休假类型:</label>
				<select  class="easyui-combobox" name="vacType" style="width:160px;">
				    <option value="0">年假</option>
				    <option value="1">事假</option>
				    <option value="2">病假</option>
				</select>
	        </div>
	        <div class="fitem">
	            <label>原因:</label>
	            <input  name="reason" class="easyui-textbox" data-options="multiline:true" style="height:70px; width: 300px">
				<input  name="id" type="hidden" value="1"/>
				<input  name="procInstId" type="hidden" />
				<input  name="status" type="hidden"/>
				<input  name="userId" type="hidden"/>
	        </div>
	        <div style="padding:20px 0px 0px 0px;">
				<a href="#" id="save" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="submitForm()" style="width:80px">申请</a>
				<a href="#" id="clear" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onclick="clearForm()" style="width:80px">重置</a>
			</div>
	    </form>
	</div>
  </body>
</html>